package com.nny.alarm;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;

public class GuideActivity extends Activity
{
	public static final int GUIDE_EDIT		= 1;
	public static final int GUIDE_LIST		= 2;
	
	static final String KEY					= "guide";
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		final Intent intent = getIntent();
		int type = intent.getIntExtra(KEY, -1);
		if(type == GUIDE_EDIT)
			setContentView(R.layout.guide_edit);
		else if(type == GUIDE_LIST)
			setContentView(R.layout.guide_list);
		else
			finish();
	}

	public boolean onTouchEvent(MotionEvent event)
	{
		this.finish();
		return true;
	}

	public static final boolean guide(Context ctx, int type)
	{
		final Settings settings = Settings.getInstance(ctx);
		if(type == GUIDE_EDIT)
		{
			 if(settings.getBoolean(Settings.KEY_GUIDE_EDIT, false))
				 return false;
			settings.set(Settings.KEY_GUIDE_EDIT, true);
			start(ctx, type);
			return true;
		}		
		if(type == GUIDE_LIST)
		{
			if(settings.getBoolean(Settings.KEY_GUIDE_LIST, false))
				return false;
			settings.set(Settings.KEY_GUIDE_LIST, true);
			start(ctx, type);
			return true;
		}
		return false;
	}
	
	protected static void start(Context ctx, int type)
	{
		Intent intent = new Intent(ctx, GuideActivity.class);
		intent.putExtra(KEY, type);
		ctx.startActivity(intent);
	}
}
